/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            storeOrderCartFeeInfo: {
                storeOrderCartFees: [],
                total: 0,
                records: 1,
                states: [],
                conditions: {
                    feeName: '',
                    state: '',
                    cartId: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            //URL取值使用getParam方法
            $that._listStoreOrderCartFees(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('store_order_cart_fee', "state", function (_data) {
                $that.storeOrderCartFeeInfo.states = _data;
            });
        },
        _initEvent: function () {
            vc.on('housekeepingFeeConfigManage', 'listHousekeepingFeeConfig', function (_param) {
                $that._listStoreOrderCartFees(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listStoreOrderCartFees(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listStoreOrderCartFees: function (_page, _rows) {
                $that.storeOrderCartFeeInfo.conditions.page = _page;
                $that.storeOrderCartFeeInfo.conditions.row = _rows;
                var param = {
                    params: $that.storeOrderCartFeeInfo.conditions
                };
                param.params.feeName = param.params.feeName.trim();
                param.params.cartId = param.params.cartId.trim();
                //发送get请求
                vc.http.apiGet('/storeOrder.queryStoreOrderCartFee',
                    param,
                    function (json, res) {
                        var _storeOrderCartFeeInfo = JSON.parse(json);
                        $that.storeOrderCartFeeInfo.total = _storeOrderCartFeeInfo.total;
                        $that.storeOrderCartFeeInfo.records = _storeOrderCartFeeInfo.records;
                        $that.storeOrderCartFeeInfo.storeOrderCartFees = _storeOrderCartFeeInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.storeOrderCartFeeInfo.records,
                            dataCount: $that.storeOrderCartFeeInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            /**_openAddHousekeepingFeeConfigModal: function () {
                vc.emit('addHousekeepingFeeConfig', 'openAddHousekeepingFeeConfigModal', {});
            },
             _openEditHousekeepingFeeConfigModel: function (_housekeepingFeeConfig) {
                vc.emit('editHousekeepingFeeConfig', 'openEditHousekeepingFeeConfigModal', _housekeepingFeeConfig);
            },
             _openDeleteHousekeepingFeeConfigModel: function (_housekeepingFeeConfig) {
                vc.emit('deleteHousekeepingFeeConfig', 'openDeleteHousekeepingFeeConfigModal', _housekeepingFeeConfig);
            },**/
            //查询
            _queryStoreOrderCartFees: function () {
                $that._listStoreOrderCartFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetStoreOrderCartFees: function () {
                $that.storeOrderCartFeeInfo.conditions.feeName = "";
                $that.storeOrderCartFeeInfo.conditions.cartId = "";
                $that.storeOrderCartFeeInfo.conditions.state = "";
                $that._listStoreOrderCartFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.storeOrderCartFeeInfo.moreCondition) {
                    $that.storeOrderCartFeeInfo.moreCondition = false;
                } else {
                    $that.storeOrderCartFeeInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
